<?php

namespace App\V3\V3_2\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use DateTimeInterface;

class DataFieldPowerAdminModel extends Model
{
    use HasFactory;

    protected $table = 'data_field_power_admin';
    protected $dateFormat = 'U';//这个时间字段被为被格式化为UNIX 时间戳的形式存储

    protected $fillable = ['admin_id','field_id','created_at','updated_at','status'];

    const USEDSTATUS = 1;
    const DELETESTATUS = 0;

    //toArray 时间转换问题
    protected function serializeDate(DateTimeInterface $date)
    {
        return $date->format('Y-m-d H:i:s');
    }

    //获取所有字段列表
    static public function getAdminPowerList($data)
    {
        return DataFieldPowerAdminModel::select(
            'field_id',
        )
            ->where([
                'admin_id' => $data['id'],
                'status' => self::USEDSTATUS,
            ])
            ->get()->toArray();

    }
}
